import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;


public class ConnectionUtils {
    private static String DRIVER;
    private static String url;
    private static String user;
    private static String password;
    static{
    	Properties props = new Properties();
    	try{
    		ClassLoader loader= ConnectionUtils.class.getClassLoader();
    		InputStream is = loader.getResourceAsStream("db.properties");
    		props.load(is);
    		DRIVER=props.getProperty("driver");
    		url=props.getProperty("url");
    		user=props.getProperty("user");
    		password=props.getProperty("password");
    		Class.forName(DRIVER);
    	}catch(Exception e){
    		e.printStackTrace();
    	}
    }
    
    public static Connection getConnection() throws Exception{
    	Connection con=DriverManager.getConnection(url, user, password);
    	return con;
    }
}
